package com.ruoyi.mayi.factory;

import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.mayi.domain.ApiLog;
import com.ruoyi.mayi.service.IApiLogService;

import java.util.TimerTask;

/**
 * 异步任务工厂
 *
 * @author yacong_liu
 * @date 2022/2/12 20:26
 */
public class AsyncTaskFactory {


    /**
     * api接口日志记录
     *
     * @param apiLog api接口日志
     * @return 任务task
     */
    public static TimerTask recordApiLog(final ApiLog apiLog) {
        return new TimerTask() {
            @Override
            public void run() {
                SpringUtils.getBean(IApiLogService.class).insertApiLog(apiLog);
            }
        };
    }
}
